//document.domain = "hexun.com";

String.prototype.getQuery = function(name) 
{ 
  var reg = new RegExp("(^|&)"+ name +"=([^&]*)(&|$)"); 
  var r = this.substr(this.indexOf("\?")+1).match(reg); 
  if (r!=null) return r[2]; return null; 
}

function getFlashObj(movieName)
{
	if (navigator.appName.indexOf("Microsoft") != -1) {
		return window[movieName];
	} else {
		return document.getElementsByName(movieName)[0];
	}
}


function G(id){
	return document.getElementById(id);
}

var str = window.location.href;
var c = str.getQuery("c");
var m = str.getQuery("m");
var n = decodeURI(str.getQuery("n"));
var p = str.getQuery("p");
var cc = str.getQuery("cc");
var cm = str.getQuery("cm");
var cn = decodeURI(str.getQuery("cn"));
var t = str.getQuery("t");
function addEvent(el,evt,fn)
{
	if (el == null)
	{
		return;
	}
	if(window.addEventListener)
	{
		el.addEventListener(evt,fn,false);
	}
	else if(window.attachEvent)
	{
		el.attachEvent('on' + evt,function(){
			fn.call(el,window.event);
		});
	}	
}
	
window.addEvent = addEvent;

// 类
var Class = {
    create : function(){
        return function(){
            this.initialize.apply(this,arguments);
        }
    }
}
var currentType = "";
// Ajax 对象
var Ajax = Class.create();

Ajax.prototype = {
    _httpRequest : null,          // httpRequest
    resultFuncr  : null,          // 返回等待方法
    resultFuncb  : null,          // 返回方法
    isPost       : null,          // 请求方式post或get
    isAsy        : null,          // 异步
    url          : null,          // 地址
    parameter    : null,          // 参数
    
    initialize : function(url,parameter,isPost,isAsy,funread,funback){
        this.url = url;
        this.parameter = parameter;
        this.isPost = isPost;
        this.isAsy = isAsy;
        this.resultFuncr = funread;
        this.resultFuncb = funback;
    },
    
    send : function(){
        
        if(window.XMLHttpRequest){
            //try { netscape.security.PrivilegeManager.enablePrivilege("UniversalBrowserRead"); } catch (exception) { alert(exception);}
            // 非IE浏览器
            this._httpRequest = new XMLHttpRequest();
            // Set request mime is text/xml
            //if(this._httpRequest.overrideMimeType)
                //this._httpRequest.overrideMimeType('text/xml');
        }
        else if(window.ActiveXObject){
            // IE浏览器
            try { this._httpRequest = new ActiveXObject("Microsoft.XMLHTTP"); } 
            catch(ex) { this._httpRequest = new ActiveXObject("Msxml2.XMLHTTP");}
        }
        
        if(this._httpRequest != null){
            
            if(this.isPost)
                this._httpRequest.open("POST",this.url,this.isAsy);
            else
                this._httpRequest.open("GET",this.url + "?" + this.parameter,this.isAsy);
            
            var request = this._httpRequest;
            var funcr = this.resultFuncr;
            var funcb = this.resultFuncb;
            this._httpRequest.onreadystatechange = function(){ Callback(request, funcr, funcb); };
            
            if(this.isPost){
                this._httpRequest.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
                this._httpRequest.setRequestHeader("Content-length", this.parameter.length);
                this._httpRequest.setRequestHeader("Connection", "close");
            }
                
            // 清除缓存
            //this._httpRequest.setRequestHeader("If-Modified-Since","0");
            this._httpRequest.setRequestHeader("Cache-Control","no-cache");     

            // 发送请求
            if(this.isPost)
                this._httpRequest.send(this.parameter); 
            else
                this._httpRequest.send(this.parameter); 
        }
    }
}
var now = Date();
// 静态方法
Callback = function(request, funcr, funcb)
{  
    if(request.readyState == 4)
	{
        // 请求状态为4表示成功
        if(request.status == 200)
		{
			now = request.getResponseHeader("Date");
            // http状态200表示成功
            if(funcb != null)
                eval(funcb + "(\"" + request.responseText + "\");");
        }
		else
		{
			if(funcb != null)
                eval(funcb + "(\"refreshDataStr('" + c + "', '" + m + "', '" + currentType + "', '')\");");
		}
    }else{
        if(request.readyState == 1){
            if(funcr != null)
                eval(funcr + "();");
        }        
    }	
}



if (m != "1" && m != "2")
{
	//alert('输入参数错误。');
	m = "2";
} 
String.prototype.isNum = function()
{
	var r = new RegExp("^[0-9]*[1-9][0-9]*$");
	return r.test(this);
}
if (!c.isNum())
{
	c = "000001";
}
//document.domain = "hexun.com";
	//0分时 1日线 2周线 3月线 4五分钟线 5十五分钟线 6三十分钟线 7小时线 8收盘线
	//标签控制（Start）
	function reset3(index)
	{
		for(var i=0;i<3;i++)
		{
			if (index == i)
			{
				G('tab'+i).className = "labelc";
			}
			else
			{
				G('tab'+i).className = "labeld";
			}
		}
	}
	function reset9(index)
	{
		for(var i=0;i<9;i++)
		{
			if (index == i)
			{
				G('tab'+i).className = "labeln";
			}
			else
			{
				G('tab'+i).className = "labelm";
			}
		}
	}
	//标签控制（end）
addEvent(window,'load',function()
{
	var flashObj = getFlashObj('stockAnalyser');
	function selectButton(index)
	{
		flashObj.selectButton(index, 10);
	}
	function selectMainType(type)
	{
		flashObj.selectButton(10, type);
	}
	function selectMainTech(tech)
	{
		flashObj.selectMainTech(tech);
	}
	function selectOffTech(tech)
	{
		flashObj.selectOffTech(tech);
	}

	//0分时 1日线 2周线 3月线 4五分钟线 5十五分钟线 6三十分钟线 7小时线 8收盘线
	/*
	标签控制原位置
	*/

	function switchTab(i)
	{
		selectButton(i);
		if (G('tab'+i).className == "labeld")
		{
			reset3(i);
		}
		else if (G('tab'+i).className == "labelm")
		{
			reset9(i);
		}
	}

	addEvent(G('tab0'),'click',function(){
		switchTab(0);
	});
	addEvent(G('tab1'),'click',function(){
		switchTab(1);
	});
	addEvent(G('tab2'),'click',function(){
		switchTab(2);
	});
	addEvent(G('tab3'),'click',function(){
		switchTab(3);
	});
	addEvent(G('tab4'),'click',function(){
		switchTab(4);
	});
	addEvent(G('tab5'),'click',function(){
		switchTab(5);
	});
	addEvent(G('tab6'),'click',function(){
		switchTab(6);
	});
	addEvent(G('tab7'),'click',function(){
		switchTab(7);
	});
	addEvent(G('tab8'),'click',function(){
		switchTab(8);
	});
	
	addEvent(G('K'),'click',function(){
		selectMainType(1);
	});
	addEvent(G('A'),'click',function(){
		selectMainType(2);
	});
	addEvent(G('T'),'click',function(){
		selectMainType(3);
	});

	addEvent(G('MA'),'click',function(){
		selectMainTech('MA');
	});
	addEvent(G('EXPMA'),'click',function(){
		selectMainTech('EXPMA');
	});
	addEvent(G('SAR'),'click',function(){
		selectMainTech('SAR');
	});
	addEvent(G('BOLL'),'click',function(){
		selectMainTech('BOLL');
	});
	addEvent(G('DKL'),'click',function(){
		selectMainTech('DKL');
	});
	
	addEvent(G('RSI'),'click',function(){
		selectOffTech('RSI');
	});
	addEvent(G('KDJ'),'click',function(){
		selectOffTech('KDJ');
	});
	addEvent(G('MACD'),'click',function(){
		selectOffTech('MACD');
	});
	addEvent(G('WR'),'click',function(){
		selectOffTech('WR');
	});
	addEvent(G('DMI'),'click',function(){
		selectOffTech('DMI');
	});
	addEvent(G('BIAS'),'click',function(){
		selectOffTech('BIAS');
	});
	addEvent(G('OBV'),'click',function(){
		selectOffTech('OBV');
	});
	addEvent(G('CCI'),'click',function(){
		selectOffTech('CCI');
	});
	addEvent(G('ROC'),'click',function(){
		selectOffTech('ROC');
	});
	addEvent(G('default'),'click',function(){
		selectMainType(1);
		G('K').checked = true;
		G('percent').checked = true;
			G('MA').checked = true;
			G('RSI').checked = true;
		selectMainTech('MA');
		selectOffTech('RSI');
		flashObj.selectCoordinate(0);
		flashObj.clearStock();

	});
	addEvent(G('code'), 'focus', function()
	{
		if (this.value=='请输入对比股票代码')
		{
			this.value='';
		}
	});
	addEvent(G('addstock'),'click',function()
	{
		if (G('compare0').checked == true)
		{
			if (G('code').value.length != 6 || !G('code').value.isNum())
			{
				alert('请输入正确的股票代码。');
				return;
			}
			else
			{
				var ajax = new Ajax("http://flashquote.stock.hexun.com/Stock_S.ASPX", "c=" + G('code').value, false, true, null, "compareStock");
				compareStock = function(res)
				{
					if (res != null && res != "")
					{
						data = res;
						if (data == "ERROR")
						{
							alert("没有找到这只股票。");
							return;
						}
						data = data.replace("<script>function(", "");
						data = data.replace("]])</script>", "");
						data = data.substring(data.indexOf(",") + 1);
						var ary = data.split(",");
						market = ary[0].replace('[', '');
						var code = ary[1];
						var name = ary[3];
						n = name;
						flashObj.addStock(code, market, name);
					}
				}
				ajax.send();
				ajax = null;
				
			}
		}
		else if (G('compare1').checked == true)
		{
			flashObj.addStock('000001', '1', '上证综指');
			n = '上证综指';
		}
		else if (G('compare2').checked == true)
		{
			flashObj.addStock('000003', '1', '上证B股');
			n = '上证B股';
		}
		else if (G('compare3').checked == true)
		{
			flashObj.addStock('399001', '2', '深证成指');
			n = '深证成指';
		}
		else if (G('compare4').checked == true)
		{
			flashObj.addStock('399108', '2', '深证B指');
			n = '深证B指';
		}
		else if (G('compare5').checked == true)
		{
			flashObj.addStock('000300', '1', '沪深300');
			n = '沪深300';
		}
		else if (G('compare6').checked == true)
		{
			flashObj.addStock('399005', '2', '企业中小板');
			n = '企业中小板';
		}
		switchTab(8);
	});
	addEvent(G('clearstock'),'click',function(){
		flashObj.clearStock();
	});

	addEvent(G('percent'),'click',function(){
		flashObj.selectCoordinate(0);
	});
	addEvent(G('gold'),'click',function(){
		flashObj.selectCoordinate(2);
	});
	addEvent(G('log'),'click',function(){
		flashObj.selectCoordinate(1);
	});
	if (G('K') != null)
	{
		G('K').checked = true;
	}
	if (G('compare0') != null)
	{
		G('compare0').checked = true;
	}
	if (G('RSI') != null)
	{
		G('RSI').checked = true;
	}
	if (G('MA') != null)
	{
		G('MA').checked = true;
	}
	if (G('percent') != null)
	{
		G('percent').checked = true;
	}
	if (G("stockname") != null)
	{
		G("stockname").innerHTML = n + "[" + c + "]";
	}
	if (G("mainstockname") != null)
	{
		G("mainstockname").innerHTML = n;
	}
	if (G("big") != null)
	{
		G("big").href = "http://stockdata.stock.hexun.com/gghq_" + c + ".shtml";
	}
	if (G('mystock') != null)
	{
		if (p == null)
		{
			G('mystock').innerHTML = "";
		}
		else
		{
			G('mystock').href = "http://mymoney.hexun.com/mystock/AddMySelfStock.aspx?StockId="+p;
		}
	}
	if (G("return") != null)
	{
		//G("return").href = "http://quote.test.hexun.com/2008/default.aspx?stockid="+c;
		addEvent(G('return'),'click',function(){
			top.location.href = "http://stockdata.stock.hexun.com/" + c + ".shtml";
		});
	}
	setOption(true);
});

var i = 0;
var close = 0;
var currentDetail = 0;
function flashText(id, value, func)
{
	setTimeout(function(){G(id).innerHTML = setGray(value)}, 200);
	setTimeout(function(){G(id).innerHTML = eval(func + "('" + value + "')")}, 400);
	setTimeout(function(){G(id).innerHTML = setGray(value)}, 600);
	setTimeout(function(){G(id).innerHTML = eval(func + "('" + value + "')")}, 800);
	setTimeout(function(){G(id).innerHTML = setGray(value)}, 1000);
	setTimeout(function(){G(id).innerHTML = eval(func + "('" + value + "')")}, 1200);
}
function getDay(id, market)
{
	currentType = "DA";
	var ajax = new Ajax("http://110.76.43.131/Quotejs/DA/" + market + "_" + id + "_DA.html", "",false,true,null,"refreshFlash");
	ajax.send();
	ajax = null;
}
function refreshFlash(data)
{
	if (data != null && data != "")
	{
		eval(data);
	}
	else
	{
		refreshDataStr(c, m, currentType, '');
	}
}
function get5Min(id, market)
{
	currentType = "M5";
	var ajax = new Ajax("http://110.76.43.131/Quotejs/M5/" + market + "_" + id + "_M5.html", "",false,true,null,"refreshFlash");
	ajax.send();
	ajax = null;
}
function getMin(id, market)
{
	currentType = "MA";
	var ajax = new Ajax("http://110.76.43.131/Quotejs/MA/" + market + "_" + id + "_MA.html", "",false,true,null,"refreshFlash");
	ajax.send();
	ajax = null;
}
function getToday(id, market)
{

	//var ajax = new Ajax("http://110.76.43.131/Stock_MI.ASPX", "m=" + market + "&c=" + id + "&t="+Math.random(),false,true,null,"refreshFlash");
	var ajax = new Ajax("http://110.76.43.131/Stock_Combo.ASPX", "mc=" + market + "_" + id + "&dt=Q,MI&t="+Math.random(),false,true,null,"refreshFlash");
	ajax.send();
	ajax = null;
}
function getQ(id, market)
{
	currentType = "MX";
	var ajax = new Ajax("http://110.76.43.131/Stock_Combo.ASPX", "mc=" + market + "_" + id + "&dt=MX&t="+Math.random(),false,true,null,"refreshFlash");
	ajax.send();
	ajax = null;
}
var loop = 0;

function refreshData(id, market, type, data)
{
	var flashObj = getFlashObj('stockAnalyser');
	
	flashObj.refreshData(id, market, n, type, data);
	
}
function refreshDataStr(id, market, type, data)
{
	var flashObj = getFlashObj('stockAnalyser');
	flashObj.refreshDataStr(id, market, n, type, data);
}
function refreshMin(id, market)
{
	if (currentDetail == 0)
	{
		type = "DL";
	}
	else if (currentDetail == 1)
	{
		type = "BD";
	}
	else if (currentDetail == 2)
	{
		type = "PS";
	}
	else
	{
		type = "DL";
	}
	var ajax = new Ajax("http://110.76.43.131/Stock_Combo.ASPX", "mc=" + market + "_" + id + "&dt=MX," + type + "&t="+Math.random(),false,true,null,"refreshFlash");
	ajax.send();
	ajax = null;
}
function refreshMinSmall(id, market)
{
	var ajax = new Ajax("http://110.76.43.131/Stock_Combo.ASPX", "mc=" + market + "_" + id + "&dt=MX&t="+Math.random(),false,true,null,"refreshFlash");
	ajax.send();
	ajax = null;
}

var oldbd = new Array();
/*
function clearDB()
{
	oldbd.splice(0, oldbd.length);
}
*/
function refreshDeal(type, data)
{
	var temp = "";
	switch(type)
	{
		case "DL":
			for(var s in data)
			{
				if (data[s] != "" && data[s] != null)
				{
					
					var arrow = "↓";
					if (data[s][0] == "--")
					{
						continue;
					}
					if (data[s][2] == "0")
					{
						continue;
					}
					if (data[s][3] == "2")
					{
						arrow = setRed(parseInt(data[s][2]/100) + "↑");
					}
					else
					{
						arrow = setGreen(parseInt(data[s][2]/100) + "↓");
					}
					temp += "<tr><td>" + data[s][0].substring(0, 2) + ":" + data[s][0].substring(2, 4) + ":" + data[s][0].substring(4, 6) + "</td><td align=\"center\">" + compareClose(data[s][1]) + "</td><td align=\"right\">" + arrow + "</td></tr>";
				}
			}
			G("dl").innerHTML = "<table width=\"90%\" border=\"0\" align=\"center\" cellpadding=\"0\" cellspacing=\"0\" style=\"line-height:20px;\">  <tr>    <td height=\"3\" colspan=\"3\"></td>     </tr>  <tr align=\"center\">    <td width=\"35%\">时间</td>    <td width=\"30%\">成交价</td>    <td>成交量</td>  </tr>" + temp + "</table>";
			break;
		case "BD":
			
			var newdata = new Array();
			var oldbdpos = 0, datapos = 0;			
			while(oldbdpos < oldbd.length || datapos < data.length)
			{
				if (oldbdpos >= oldbd.length)
				{
					newdata.push(data[datapos]);
					datapos++;
				}
				else if (datapos >= data.length)
				{
					newdata.push(oldbd[oldbdpos]);
					oldbdpos++;
				}
				else if (oldbd[oldbdpos][0] < data[datapos][0])
				{
					newdata.push(oldbd[oldbdpos]);
					oldbdpos++;
				}
				else if (oldbd[oldbdpos][0] > data[datapos][0])
				{
					newdata.push(data[datapos]);
					datapos++;
				}
				else if (oldbd[oldbdpos][2] != data[datapos][2])
				{
					newdata.push(oldbd[oldbdpos]);
					newdata.push(data[datapos]);
					oldbdpos++;
					datapos++;
				}
				else
				{
					newdata.push(oldbd[oldbdpos]);
					oldbdpos++;
					datapos++;
				}
			}
			data = newdata;
			
			for(var s in data)
			{
				if (data[s] != "" && data[s] != null)
				{
					if (data[s][0] == "--")
					{
						continue;
					}
					if (data[s][2] == "0")
					{
						continue;
					}
					var arrow = "↓";
					if (data[s][3] == "2")
					{
						arrow = setRed(parseInt(data[s][2]/100) + "↑");
					}
					else
					{
						arrow = setGreen(parseInt(data[s][2]/100) + "↓");
					}
					temp = "<tr><td>" + data[s][0].substring(0, 2) + ":" + data[s][0].substring(2, 4) + ":" + data[s][0].substring(4, 6) + "</td><td align=\"center\">" +	compareClose(data[s][1]) + "</td><td align=\"right\">" + arrow + "</td></tr>" + temp;
				}
			}
			G("bd").innerHTML = "<table width=\"90%\" border=\"0\" align=\"center\" cellpadding=\"0\" cellspacing=\"0\" style=\"line-height:20px;\">  <tr>    <td height=\"3\" colspan=\"3\"></td>     </tr>  <tr align=\"center\">    <td width=\"35%\">时间</td>    <td width=\"30%\">成交价</td>    <td>成交量</td>  </tr>" + temp + "</table>";
			oldbd = data;
			break;
		case "PS":
			for(var s in data)
			{
				if (data[s] != "" && data[s] != null)
				{
					if (data[s][0] == "--")
					{
						continue;
					}
					if (data[s][1] == "0")
					{
						continue;
					}
					temp += "<tr><td align=\"center\">" + compareClose(data[s][0]) + "</td><td align=\"center\">" + parseInt(data[s][1]/100) + "</td></tr>";
				}
			}
			G("ps").innerHTML = "<table width=\"90%\" border=\"0\" align=\"center\" cellpadding=\"0\" cellspacing=\"0\" style=\"line-height:20px;\">  <tr>    <td height=\"3\" colspan=\"3\"></td>     </tr>  <tr align=\"center\">    <td width=\"50%\">成交价</td>    <td>成交量</td>  </tr>" + temp + "</table>";
			break;
	}
}
function getDL(id, market)
{
	var ajax = new Ajax("http://110.76.43.131/Stock_DL.ASPX", "m=" + market + "&c=" + id + "&t="+Math.random(),false,true,null,"refreshFlash");
	ajax.send();
	ajax = null;
}
function getBD(id, market)
{
	var ajax = new Ajax("http://110.76.43.131/Stock_BD.ASPX", "m=" + market + "&c=" + id + "&t="+Math.random(),false,true,null,"refreshFlash");
	ajax.send();
	ajax = null;
}
function getPS(id, market)
{
	var ajax = new Ajax("http://110.76.43.131/Stock_PS.ASPX", "m=" + market + "&c=" + id + "&t="+Math.random(),false,true,null,"refreshFlash");
	ajax.send();
	ajax = null;
}
function setOption(disabled)
{
	if (G('option') == null)
	{
		return;
	}
	var a = G('option').getElementsByTagName("input");
    for (var i = 0; i < a.length; i++)
    {
        if (a[i].type == "radio")
        {
            a[i].disabled = disabled;
        }
    }
}
function refreshMain(yclose, open, high, low, price, buyprice1, buyvolume1, buyprice2, buyvolume2, buyprice3, buyvolume3, buyprice4, buyvolume4, buyprice5, buyvolume5, sellprice1, sellvolume1, sellprice2, sellvolume2, sellprice3, sellvolume3, sellprice4, sellvolume4, sellprice5, sellvolume5, volume, amount, now, volumerate, marketrate, changerate, inVolume, outVolume)
{
	if (G("yclose") == null)
	{
		return;
	}
	close = yclose;
	G("yclose").innerHTML = yclose;
	if (open != "0.00")
	{
		G("open").innerHTML = compareClose(open);	
		G("high").innerHTML = compareClose(high);
		G("low").innerHTML = compareClose(low);
		if (G("price").innerHTML != compareClose(price))
		{
			G("price").innerHTML = compareClose(price);
			flashText("price", price, "compareClose");
		}
		G("buyprice1").innerHTML = compareClose(buyprice1);
		G("buyvolume1").innerHTML = setRed(parseInt(buyvolume1/100));
		G("buyprice2").innerHTML = compareClose(buyprice2);
		G("buyvolume2").innerHTML = setRed(parseInt(buyvolume2/100));
		G("buyprice3").innerHTML = compareClose(buyprice3);
		G("buyvolume3").innerHTML = setRed(parseInt(buyvolume3/100));
		G("buyprice4").innerHTML = compareClose(buyprice4);
		G("buyvolume4").innerHTML = setRed(parseInt(buyvolume4/100));
		G("buyprice5").innerHTML = compareClose(buyprice5);
		G("buyvolume5").innerHTML = setRed(parseInt(buyvolume5/100));

		G("sellprice1").innerHTML = compareClose(sellprice1);
		G("sellvolume1").innerHTML = setGreen(parseInt(sellvolume1/100));
		G("sellprice2").innerHTML = compareClose(sellprice2);
		G("sellvolume2").innerHTML = setGreen(parseInt(sellvolume2/100));
		G("sellprice3").innerHTML = compareClose(sellprice3);
		G("sellvolume3").innerHTML = setGreen(parseInt(sellvolume3/100));
		G("sellprice4").innerHTML = compareClose(sellprice4);
		G("sellvolume4").innerHTML = setGreen(parseInt(sellvolume4/100));
		G("sellprice5").innerHTML = compareClose(sellprice5);
		G("sellvolume5").innerHTML = setGreen(parseInt(sellvolume5/100));
		if (G("volume").innerHTML != parseInt(volume/100))
		{
			G("volume").innerHTML = parseInt(volume/100);
			flashText("volume", parseInt(volume/100), "setBlack");
		}
		if (G("amount").innerHTML != parseInt(amount/10000))
		{
			G("amount").innerHTML = parseInt(amount/10000);
			flashText("amount", parseInt(amount/10000), "setBlack");
		}
		G("avgprice").innerHTML = compareClose((amount/volume).toFixed(2));
		if (G("now").innerHTML != parseInt(now/100))
		{
			G("now").innerHTML = parseInt(now/100);
			flashText("now", parseInt(now/100), "setBlack");
		}
		G("volumerate").innerHTML = volumerate;
		G("marketrate").innerHTML = marketrate;
		G("changerate").innerHTML = (changerate * 100).toFixed(2) + "%";
		G("risefallvalue").innerHTML = (price-yclose).toFixed(2);
		G("risefallframe").innerHTML = (100*(price-yclose)/yclose).toFixed(2)+"%";

		var BuySellSub = parseInt((parseInt(buyvolume1)+parseInt(buyvolume2)+parseInt(buyvolume3)+parseInt(buyvolume4)+parseInt(buyvolume5)-parseInt(sellvolume1)-parseInt(sellvolume2)-parseInt(sellvolume3)-parseInt(sellvolume4)-parseInt(sellvolume5))/100);
		if (BuySellSub > 0)
		{
			if (G("BuySellSub").innerHTML != setRed(BuySellSub))
			{
				G("BuySellSub").innerHTML = setRed(BuySellSub);
				flashText("BuySellSub", BuySellSub, "setRed");
			}
			
		}
		else if (BuySellSub < 0)
		{
			if (G("BuySellSub").innerHTML != setGreen(BuySellSub))
			{
				G("BuySellSub").innerHTML = setGreen(BuySellSub);
				flashText("BuySellSub", BuySellSub, "setGreen");
			}
			
		}
		else
		{
			if (G("BuySellSub").innerHTML != BuySellSub)
			{
				G("BuySellSub").innerHTML = BuySellSub;
				flashText("BuySellSub", BuySellSub, "setBlack");
			}
		}
		
		if (parseInt(volume)==0 || parseInt(buyvolume1)+parseInt(buyvolume2)+parseInt(buyvolume3)+parseInt(buyvolume4)+parseInt(buyvolume5)+parseInt(sellvolume1)+parseInt(sellvolume2)+parseInt(sellvolume3)+parseInt(sellvolume4)+parseInt(sellvolume5) == 0)
		{
			G("BuySellRate").innerHTML = "0%";
		}
		else
		{
			var BuySellRate = 100*(parseInt(buyvolume1)+parseInt(buyvolume2)+parseInt(buyvolume3)+parseInt(buyvolume4)+parseInt(buyvolume5)-parseInt(sellvolume1)-parseInt(sellvolume2)-parseInt(sellvolume3)-parseInt(sellvolume4)-parseInt(sellvolume5))/(parseInt(buyvolume1)+parseInt(buyvolume2)+parseInt(buyvolume3)+parseInt(buyvolume4)+parseInt(buyvolume5)+parseInt(sellvolume1)+parseInt(sellvolume2)+parseInt(sellvolume3)+parseInt(sellvolume4)+parseInt(sellvolume5));
			if (BuySellRate > 0)
			{
				if (G("BuySellRate").innerHTML != setRed(BuySellRate.toFixed(2) + "%"))
				{
					G("BuySellRate").innerHTML = setRed(BuySellRate.toFixed(2) + "%");
					flashText("BuySellRate", BuySellRate.toFixed(2) + "%", "setRed");
				}
			}
			else if (BuySellRate < 0)
			{
				if (G("BuySellRate").innerHTML != setGreen(BuySellRate.toFixed(2) + "%"))
				{
					G("BuySellRate").innerHTML = setGreen(BuySellRate.toFixed(2) + "%");
					flashText("BuySellRate", BuySellRate.toFixed(2) + "%", "setGreen");
				}
			}
			else
			{
				if (G("BuySellRate").innerHTML != BuySellRate.toFixed(2) + "%")
				{
					G("BuySellRate").innerHTML = BuySellRate.toFixed(2) + "%";
					flashText("BuySellRate", BuySellRate.toFixed(2) + "%", "setBlack");
				}
			}
		}
		if (G("inVolume").innerHTML != setGreen(parseInt(inVolume/100)))
		{
			G("inVolume").innerHTML = setGreen(parseInt(inVolume/100));
			flashText("inVolume", parseInt(inVolume/100), "setGreen");
		}
		if (G("outVolume").innerHTML != setRed(parseInt(outVolume/100)))
		{
			G("outVolume").innerHTML = setRed(parseInt(outVolume/100));
			flashText("outVolume", parseInt(outVolume/100), "setRed");
		}
	}
}

function compareClose(value)
{
	if (parseFloat(value) > parseFloat(close))
	{
		return setRed(value);
	}
	else if (parseFloat(value) < parseFloat(close))
	{
		return setGreen(value);
	}
	else
	{
		return value;
	}
}

function setBlack(value)
{
	return value;
}

function setRed(value)
{
	return "<span style=\"color: red;\">" + value + "</span>";
}
function setGreen(value)
{
	return "<span style=\"color: green;\">" + value + "</span>";
}
function setGray(value)
{
	return "<span style=\"color: gray;\">" + value + "</span>";
}
function frequency()
{
	return 6;
}
